Repository navigation
feat(durable): decode service results through WithEventDataDecoder and park undecodable ones - #258
Merged
Merged
Conversation
reka18
added a commit
that referenced
this pull request
Nov 17, 2026
Fire looked only for a parent Fire a context refused after handing the event's effects to the actor system. A ctx that ended while the Fire spawned its actors could cost a message one actor sent another, which no Fire reports, so the Fire was journaled and Recover delivered that message under a live context, which live never applied. A Fire that spawned an actor now rechecks ctx after the absorb, as Tick and RunService do: it fails the Handle and records nothing, and the event fires again on a recovered Handle. A Fire that spawned no actor still records when its context ends once the kernel applied the event. DeliverToActor already rechecks ctx after the delivery. Start and Recover keep their documented rule: a context that ends once their actors spawned, with no parent Fire refused, doesn't fail them. Document what RunService does with a result whose JSON form won't decode, or that has no JSON form: the onDone Assign runs once on a stand-in and the onDone state starts its actors and services before RunService returns ErrHandleFailed and records nothing. Keep results JSON round-trippable, and have an onDone Assign check the payload's type. A stacked change, #258, refuses such a result before any Assign runs. Tests: - Fire: a context that ends while the Fire spawns actors records nothing, and the event fires again on the recovered Handle. - Fire: without an actor palette, a context that ends once the kernel applied the event still records. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
reka18
added a commit
that referenced
this pull request
Nov 17, 2026
* fix(durable): dispatch effects from Start, Tick and RunService Only Fire dispatched domain effects. Tick and RunService now record a step through the same helper as Fire, then dispatch its effects as Fire does, after the append and before any checkpoint. A failed dispatch fails the Handle before its checkpoint, so a later checkpoint can't compact the effect away, and Recover retries it. Start applies the initial entry's effects before the baseline, so a handler failure leaves no instance; they're at-least-once. DeliverToActor records through the same helpers, and persistStep is gone. - EffectInstance gives a handler its instance id, because effect ids repeat across instances. - state.ServiceRunner gains WithResultTransform, so a service's result reaches the machine in the JSON-decoded form a replay supplies, and an error message-only. A transform that returns no error for an unbound service doesn't turn it into a success. A result whose JSON form won't decode fails RunService and records nothing. - One helper calls the effect handler for Start, a step and Recover, and turns a handler panic into ErrEffectDispatch; the shared dispatch path does the same for a DispatchStore whose Dispatched or MarkDispatched panics or fails. A service error whose Error method panics settles with a message saying so, its invalid UTF-8 replaced. - A KindedEffect that won't marshal, or whose MarshalJSON panics, is recorded by id and kind, with the reason in Meta under crucible.marshalError, on every path including Fire, and dispatches as any effect does. - Recover re-sends a tick's and a service settle's effects. journalFormat is 2, and Recover sends them only for a Record of format 2 or later, so it doesn't send an older version's, which never dispatched them. - An effect handler wired with a Store that isn't a DispatchStore is refused by Start, Recover and the stateless Runner.Fire, and by dispatch itself, with the new ErrNoDispatchStore, a permanent error that doesn't match ErrEffectDispatch. It used to skip every effect silently. - Tick hands each fired timer transition's effects to the service runner and then the actor system, under the step's context, live and on replay for a tick of format 2 or later, so a timer that leaves a state stops its service and actor, and one that enters a state starts and spawns them. This covers #236's Tick items and unskips its two tests. - A settle leaves its follow-on services to the ServiceRunner, which already armed them, as replay does, and a checkpoint written without a service registry keeps the settled services. Effects from a parent transition an actor drives are still not dispatched (#257). Relates to #214. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(durable): recheck Tick's context after it spawns actors Tick checked ctx before handing the fired timers' effects to the service runner and the actor system, then only looked for a parent Fire a context refused. A ctx that ended while the tick spawned its actors could cost a message one actor sent another, which no Fire reports, so the tick was journaled and Recover delivered that message under a live context, which live never applied. Tick now rechecks ctx after the absorb, as RunService does after its settle: it fails the Handle and records nothing, and a recovered Handle re-arms the timer. Tests, each committed either way: - Tick: a context that ends while the tick spawns actors records nothing. - Fire, Tick and RunService dispatch a recorded step's effects under the caller's context alike: a handler that ignores an ended context applies the effect and the step succeeds; one that honors it fails the Handle with ErrEffectDispatch, and Recover sends the effect once. - RunService: a result whose JSON form won't decode, or that has no JSON form, settles onDone before the step fails. Its Assign runs on the stand-in, and the state it enters spawns its actor, then RunService returns ErrHandleFailed and records nothing. A reducer that panics on the stand-in refuses the Fire, and RunService still returns ErrHandleFailed. This pins today's behavior for a design decision. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(durable): recheck Fire's context after it spawns actors Fire looked only for a parent Fire a context refused after handing the event's effects to the actor system. A ctx that ended while the Fire spawned its actors could cost a message one actor sent another, which no Fire reports, so the Fire was journaled and Recover delivered that message under a live context, which live never applied. A Fire that spawned an actor now rechecks ctx after the absorb, as Tick and RunService do: it fails the Handle and records nothing, and the event fires again on a recovered Handle. A Fire that spawned no actor still records when its context ends once the kernel applied the event. DeliverToActor already rechecks ctx after the delivery. Start and Recover keep their documented rule: a context that ends once their actors spawned, with no parent Fire refused, doesn't fail them. Document what RunService does with a result whose JSON form won't decode, or that has no JSON form: the onDone Assign runs once on a stand-in and the onDone state starts its actors and services before RunService returns ErrHandleFailed and records nothing. Keep results JSON round-trippable, and have an onDone Assign check the payload's type. A stacked change, #258, refuses such a result before any Assign runs. Tests: - Fire: a context that ends while the Fire spawns actors records nothing, and the event fires again on the recovered Handle. - Fire: without an actor palette, a context that ends once the kernel applied the event still records. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(durable): one ctx recheck rule for Fire and Tick after the absorb Fire rechecked an ended ctx after its absorb only when it spawned an actor, and Tick whenever a timer fired. Neither matched what an ended ctx can cost. A Fire that sent a running actor a message (SendTo, ForwardTo) recorded though the actor refused the message under the ended ctx, so the message was lost for good: the caller saw success, and a recovered Handle starts the actor fresh. A Tick on a machine with timers and services but no actor palette failed its Handle when ctx ended during the absorb, where the same Fire records, though handing services to the runner runs nothing ctx can refuse. Fire and Tick now share one rule: recheck ctx after the absorb when the step handed a wired actor system a spawn or a message to an actor. Stopping an actor, a response with no sender, and timers and services don't count, so a Fire that touched no actor still records when ctx ends after the apply. Tick still fails when ctx ends while its timers fire. RunService keeps rechecking ctx whatever its absorb did: the service itself ran under ctx, so its outcome can be one ctx's ending caused. The RunService doc no longer names a pending change. Tests, each committed either way: - Fire (by SendTo and by ForwardTo) and Tick: a ctx that ends while the step messages a running actor records nothing, and the message is delivered when the step runs again on a recovered Handle. - Fire and Tick: with timers and a service but no actor palette, a ctx that ends after the kernel applied the step records, and the service is in flight live and recovered. - Fire: a ctx that ends while the step stops an actor and responds to no sender records. - Recover: an older version's journal, of format 0 or 1, whose tick left a state with its service in flight, recovers with the service in flight; a checkpoint then drops it, a settle follows, and every later Recover fails with "no in-flight service to settle". This pins today's behavior for a decision. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(durable): forward a step's event, skip spawns for left states, fail only on refused parent Fires A parent's forwardTo forwarded nothing: Fire and Tick handed the actor system their effects without the event. Fire now absorbs through AbsorbFor with its event, and Tick with each timer's event, rebuilt from the trace with the Runner's event codec. Actor deliveries aren't replayed, so Recover starts the actor fresh, as for a SendTo. This was already so on main for Fire. A step could spawn an actor for a state a parent Fire its absorb drove had already left, as when one region's actor exits another region's state, by one Fire or by timers that fire in one Tick. The live Handle ran an orphan Recover never spawns. The step now feeds the actor system one effect at a time and skips a state's spawn whose actor a parent Fire since stopped. Fire and Tick no longer fail the Handle because their context ended after they handed actors work; only a parent Fire a context refused fails them, as for Start and Recover. A message an actor refuses under the ended context is lost, as actor deliveries are across Recover, and failing the step would have the retry run actor behaviors again. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(durable): skip left states' spawns at Start, Recover and later timers; decode a timer's event only to forward it c393fd3 skipped a step's spawn for a state a parent Fire had left, but only in Fire and Tick. Start and Recover still spawned the configuration's actors in one batch, so when one region's actor sent the parent a message as it started that left another region's state, that state's actor spawned after, and ran where a Recover from the journal never spawns it. Start and Recover's new actors now go through the same per-effect absorb. Recover respawns the actors that were running in one batch, so when one's respawn fails with an onError that leaves another of their states, it now stops each respawned actor whose state isn't active. Within a Tick, a timer that entered a state spawned its actor even when a later timer of the same tick left it, so the actor's behavior ran before the later timer stopped it. A step now skips a state's spawn that a later effect of the step stops, the later timers' included. Checking the declaring state against the configuration instead wasn't enough on its own: state exposes active leaves only, and a state left and entered again in one step is active at the end, so its first spawn would still run. Tick decoded every fired timer's event through the event codec and dropped a decode error. It now decodes only for a forwardTo an actor system can carry. On a decode error it forwards nothing, records the tick, dispatches its effects, and returns the codec's error with the results; the Handle carries on, as when an actor can't take a message. A step with no event to forward no longer hands the actor system a ForwardEvent, which it delivered as a nil event. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * docs(durable): say an actor-driven forwardTo still hands the child a nil event Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(durable): name the step in a dispatch-tracking panic A panic in the Store's Dispatched or MarkDispatched now reports the step it dispatched for, as it did before. The changelog now says a stateless Runner.Fire on a Store without dispatch tracking returns ErrNoDispatchStore. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> --------- Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
reka18
force-pushed
the
feat/durable-service-result-decoder
branch
from
November 18, 2026 04:17
96cd20a to
16de926
Compare
Contributor
Author
Review findings at 16de926The AI reviewers' single pass over this range checked every review label and found no blockers. Each candidate was verified against the code. Two non-blockers were real, and both are fixed in 57116fa:
One candidate was refuted: a checkpoint listing a service as both settled and parked. No writer can produce that, because settling and parking keep the two maps disjoint. Gates on go1.27.4: |
reka18
force-pushed
the
fix/durable-checkpoint-cadence
branch
from
November 18, 2026 16:55
2f81ae3 to
30deaf1
Compare
2 tasks done
Contributor
Author
Decisions for Temple to ratifyI made these calls in this PR. Each is a suggestion for you to confirm or change.
|
This was referenced Nov 18, 2026
…d park undecodable ones Builds on #235's effect dispatch. A service result now decodes through the Runner's EventDataDecoder for the invocation's onDone event, live and on replay, as a WithEventData payload does, so a decoder hands Assign the service's own type; without one the result arrives in JSON's generic form. A service error stays message-only. - state: ServiceRunner.WithResultTransform's function takes the event that carries the outcome and returns an explicit abort: func(event E, result any, err error) (out any, outErr error, abort error). It runs on every settle, before any event fires, and an abort fires no event. Each activation carries a generation, so a settle can't settle a later activation of its service: Tick returns an empty slice, and SettleDone and SettleError return false, for a stale settle or abort. - durable: a result the decoder refuses, or decodes as another type than the service returned, is parked: RunService returns ErrEventDataEncoding with the Handle healthy, records the result with its Go type and import path, and settles nothing. The service stays in flight and its ServiceFn never runs again; a RunService after Recover with a fixed decoder settles the parked result. Checkpoints carry parked results in parkedServices, a timer or Fire that leaves the state discards them, and a checkpoint written without a registry keeps them. A ctx that ended during the ServiceFn parks nothing, and a result with no JSON form aborts the settle. - durable: every settle records the result's Go type and replay holds the decoder to it. The journal records the JSON the live settle decoded. A decoder may return json.Number for any service result. A typed nil result keeps its type through the decoder. - durable: a service result in a Record of format 3 or lower replays in JSON's generic form through no decoder, as the version that wrote it did. - durable: Recover, the stateless Runner.Fire, StateAt and Steps refuse a journal whose checkpoint or any Record records a format above this version's, including a checkpoint envelope of a shape this version can't unmarshal, and refuse a Record of a lower format than any before it as an older version appending to a newer journal. The CHANGELOG says not to run mixed versions on one instance (#253). Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
reka18
force-pushed
the
feat/durable-service-result-decoder
branch
from
November 19, 2026 15:47
57116fa to
6d3453d
Compare
Cuts the parts of #258 beyond #264's scope, under the greenfield rule: durable has never been released, so a journal format bump and old-journal compatibility gates have nothing to protect. Cut: - Journal format 4: journalFormat is back to main's timersFirstFormat (3), and decodedResultsFormat is gone. Replay always decodes a recorded service result through the Runner's EventDataDecoder for the onDone event, exactly as the live settle did, and is held to the recorded Go type; the decoded parameter and the legacyResult replay of format 0-3 results as generic JSON are gone with it. Deleted journal_format_service_test.go, which only pinned that legacy replay, and the format-4 parts of journal_format_internal_test.go (its checkFormats and checkNotNewer tables and the older-reader parked-entry test); what's left pins main's checkFormat only. - The newer-journal refusal: checkNotNewer, newerFormatOf and the unmarshalCheckpoint probe for a newer format's envelope are gone; 6d3453d was already out. - The mixed-version extension of the format check: checkFormats (the running max, the upfront move, its extension to StateAt and Steps) is gone; checkFormat is exactly main's, called per Record in Recover's and replayThrough's loops, as on main. Deleted journal_format_midtail and journal_format_mixed, and the format-extension tests of journal_format_stateat; its sentinel test, which pins kept parking behavior, moved to result_decoding_scenarios_test.go, and forkMachine, whose format tests are gone, to service_activation_test.go, its only remaining user. Main's format machinery from #236/#237 is unchanged: checkFormat, the format constants, unmarshalCheckpoint, store.go's Record.Format docs and StateAt/Steps all diff empty against origin/main. Kept: typed decode live and on replay, parking, the abort return, activation generations, and the Type record with its replay check. Wording fixes: - state: WithResultTransform's doc says f gets the invocation's onDone event for an incoming result and its onError event for an incoming error, and reconciles that with the outErr that settles through onError; the state CHANGELOG entry matches. - durable: decodedAsRecorded's type-mismatch error states got versus want plainly, like its sibling branches, without "of the same name or not" and without printing the same type twice. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
reka18
force-pushed
the
feat/durable-service-result-decoder
branch
from
November 19, 2026 17:04
6d3453d to
889d948
Compare
reka18
marked this pull request as ready for review
November 19, 2026 17:07
…peAlias Every settle journals the result's full Go type name, and replay holds the decoder to it, so a pure refactor that moves or renames the type failed Recover and StateAt with ErrEventDataEncoding for every journal already settled under the old name. WithResultTypeAlias tells the Runner what a recorded name now means: a value of the renamed type settles results recorded under the old name, on every path that holds a result to its recorded name -- Recover from the journal or a checkpoint, StateAt, and a RunService settling a parked result read back from the journal or a checkpoint. Every other recorded name is checked strictly, exactly as before; a result parked by the Handle itself stays held to its own type, as live. A rename is one hop: an alias never chains through another. Bad input changes nothing, as the other Runner options, leaving the strict check standing. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…as in refusals A recorded name WithResultTypeAlias claimed for two different types now drops that name's alias entirely, instead of the first registration standing: whichever order the two arrive in, and a later registration, for any type, can't bring it back, so the strict check stands for that name, as with no option at all. An empty recorded name, a nil current value, a name aliased to its own current type, and an idempotent repeat of one rename behave as before. A refusal now says which type to decode as. When an alias covers the recorded name, the message names the recorded type and the aliased type and says to decode as the aliased one; when the name agrees and the value could only be another type a parked result carries, the message says the result is held to the type this Handle parked, and says "another type of the same name" only when the names really are the same. The option's doc spells the recorded name the way the journal records it — a leading * for pointers, type arguments for generics — and points at the refusal, which prints the exact recorded name to copy. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
Contributor
Author
Decisions for Temple to ratify: WithResultTypeAliasI made these calls while adding the alias option. Each is a suggestion for you to confirm or change.
|
joshua-temple
approved these changes
Nov 23, 2026
reka18
added a commit
that referenced
this pull request
Nov 23, 2026
…delivered them An actor's done data reached the parent as the behavior's own Go value on the live run and as JSON's generic form on replay, so a parent reducer saw two shapes for one transition (#256): an order live, a map after Recover. An actor's error kept its raw message live and the U+FFFD-replaced one a Store keeps on replay, and an error whose Error method panics — a typed nil, which a host's own ActorInstance can settle with — crashed the host through the journal's Error() call. - state: ActorSystem.WithSettleTransform rewrites every actor outcome before it settles, whether a delivery, a panic the actor raised while stepping, or SettleError settles it, mirroring ServiceRunner.WithResultTransform: it gets the event that will carry the outcome and runs before the actor is marked done and before the routing Fire. A non-nil abort fires nothing and leaves the actor running, reported as the ServiceRunner's abort is. - durable: the Runner settles its actors through the transform the service seam uses (#258's replayableOutcome, generalized to name its outcome), so an actor's done data decodes through WithEventDataDecoder for the parent's onDone event, live as on replay; an error is message-only, normalized; and one whose Error method panics settles with a message saying so. The journal records the JSON the live settle decoded with the done data's Go type, in actor entries, and replay holds the decoder to that type, as a recorded service result's replay does. - durable: there is no parking for an actor outcome, as a service result that won't decode has. Done data that won't decode, or decodes as another type than the actor produced, aborts the settle, fires nothing, and fails the Handle — the delivery, or the Fire, Tick or RunService whose absorb drove the settle — recording nothing, so the actor runs again on Recover. Start and Recover fail the same way when a settle their spawns drive aborts. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
reka18
added a commit
that referenced
this pull request
Nov 24, 2026
…delivered them (#268) * fix(durable): replay an actor's done data and errors as the live run delivered them An actor's done data reached the parent as the behavior's own Go value on the live run and as JSON's generic form on replay, so a parent reducer saw two shapes for one transition (#256): an order live, a map after Recover. An actor's error kept its raw message live and the U+FFFD-replaced one a Store keeps on replay, and an error whose Error method panics — a typed nil, which a host's own ActorInstance can settle with — crashed the host through the journal's Error() call. - state: ActorSystem.WithSettleTransform rewrites every actor outcome before it settles, whether a delivery, a panic the actor raised while stepping, or SettleError settles it, mirroring ServiceRunner.WithResultTransform: it gets the event that will carry the outcome and runs before the actor is marked done and before the routing Fire. A non-nil abort fires nothing and leaves the actor running, reported as the ServiceRunner's abort is. - durable: the Runner settles its actors through the transform the service seam uses (#258's replayableOutcome, generalized to name its outcome), so an actor's done data decodes through WithEventDataDecoder for the parent's onDone event, live as on replay; an error is message-only, normalized; and one whose Error method panics settles with a message saying so. The journal records the JSON the live settle decoded with the done data's Go type, in actor entries, and replay holds the decoder to that type, as a recorded service result's replay does. - durable: there is no parking for an actor outcome, as a service result that won't decode has. Done data that won't decode, or decodes as another type than the actor produced, aborts the settle, fires nothing, and fails the Handle — the delivery, or the Fire, Tick or RunService whose absorb drove the settle — recording nothing, so the actor runs again on Recover. Start and Recover fail the same way when a settle their spawns drive aborts. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(state): settle only the actor a transform ran for, and document Deliver's abort A settle whose WithSettleTransform function ran while the actor was stopped and spawned again under the same id settled the new actor with the old outcome, or reported its abort as though the new actor were the one the transform ran for. The settle now holds to the *runningActor it began for, still running: when the actor under the id is another one it returns false, fires nothing, and reports no abort, leaving the new actor running, as the ServiceRunner's stale settle does for a re-armed activation. A deterministic test drives the respawn from inside the transform — the supervisor leaves supervising and re-enters it, which stops the child and spawns a fresh one under the same id — and mutation-checks both branches: dropping either identity check fails it. - state: Deliver's and WithSettleTransform's documentation now say an abort from a settle a delivery drives isn't reported to Deliver's caller: Deliver returns only whether it found the actor running, so the actor stays running and the host sees the abort by calling Tick or SettleError itself; the durable Runner reports it through the Handle. - durable: the type check a replay holds a recorded outcome to (decodedAsRecorded) now takes the outcome's name the way decodedAsPassed does, so an actor's done-data a Recover's decoder returns as another type fails saying "actor done-data", not "service result". Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(durable): hold a renamed actor done-data type to WithResultTypeAlias An actor's done-data is held to the Go type the live settle recorded, so the rename concern WithResultTypeAlias answers for service results applies to it: a pure refactor that moves or renames the type failed Recover and StateAt for every journal already settled under the old name, with no way to tell the Runner what the recorded name now means. The alias now covers actor done-data on every replay path — Recover from the journal, Recover from a checkpoint's tail, and StateAt — through the same replayableOutcome transform the live settle and a recorded service result's replay use, with no new exported API: the option's doc comment now says it covers both outcomes. A decoder that returns the aliased type settles the done-data, and every other recorded name is held to strictly, exactly as before. The refusal wording matches a recorded service result's, naming the done-data and, when an alias covers the name, the aliased type to decode as. Tests cover Recover and StateAt from the journal and a Recover from a checkpoint whose compacted tail holds the settle, in the style of TestResultTypeAlias_RenamedSettledResult, and are mutation-checked: dropping the alias lookup on the actor path fails them. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(durable): skip the settle transform when nothing is routed, and fill in the review's docs and probe The settle transform ran for every settle, routed or not, so an actor spawned with no onDone for its outcome — a dynamic spawn; an invoked actor always routes, firing the zero event its unset outcome leaves — whose Output() won't encode aborted a settle that would otherwise have been the fire-and-forget no-op it is without the transform, failing the delivery's Handle for an outcome nothing consumes. The transform now runs only when the settle routes a completion, to the invocation's onDone for a success or its onError for a failure; a settle that routes nothing runs no transform, aborts nothing, fires nothing, journals nothing, and LastOutput and LastError keep the raw outcome, exactly as on main. The staleness checks are unchanged. The docs claimed a host could see a delivery-driven abort by calling Tick after it; it can't, because the delivery drained the mailbox, so that Tick returns early. The Deliver doc, the WithSettleTransform doc and state's CHANGELOG now say the abort is never recoverable through Deliver: it's visible only to a host that drives Tick itself, or through SettleError, and the durable Runner's Handle, which reports it, is the intended channel. WithEventDataDecoder's doc gains the actor done-data paragraph its README and doc.go already carry, and durable's actor docs note the unrouted rule. New tests pin the unrouted settle as a no-op in state — no transform call for an output that won't encode, for the zero event an onDone-less settle would hand a decoder that refuses it, or for a failure, which escalates as without the transform — and through durable, where the channeled output settles without failing the Handle and Recover and StateAt replay the run, and a decoder that refuses the zero event is never consulted. A probe drives one Fire whose absorb finishes two actors with distinct done data and asserts each journal entry's Data and Type and each onDone Assign's value, live, after Recover and through StateAt, catching a swapped or dropped settle relay. Both are mutation-checked: the transform back ahead of the route check turns the unrouted tests red, and a one-behind settle slot turns the probe red. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(state,durable): route an invoked actor only through outcomes its invoke declared An InvokeActor with no WithInvokeOnDone counted as routed: invokeOutcome boxes the zero event, so the spawn's e.OnDone.(E) always succeeded and hasDone was true for every invoked actor. A success with no onDone then ran the settle transform and consulted the event-data decoder for the zero event before the parent refused it, so a strict per-event decoder failed the Handle — DeliverToActor, Fire and Tick, live and again after every Recover — where main journaled a refused fire and kept going. The same held for a failure with no onError, and for a spawn that failed to start: the zero event fired where a dynamic spawn escalates. The invocation IR now records HasOnDone / HasOnError, set only when the option was given, and SpawnActor carries HasDone / HasError from the invoke options or the spawn params' presence, so the ActorSystem routes on what was declared rather than on the zero event an unset outcome leaves: a success with no onDone settles as the fire-and-forget no-op a dynamic spawn's always was, and a failure or failed spawn with no onError escalates, as a dynamic spawn's does. The Invocation fields are additive omitempty wire fields appended to the frozen shape; services are untouched, and a spawn that declares the zero event itself still routes it. Replay compat: a journal a version before this change wrote can hold a refused settle — the zero-event settle of an onDone-less invoke — with its done-data recorded and no type. Replay now never decodes the data of a fire whose replay will be refused; it re-fires the recorded event plainly and meets the same refusal, so Recover and StateAt succeed on those histories under a strict decoder, as they did on main. New tests pin each half: the invoked-actor unrouted settle in state (no transform call for the undeclared outcome, success a no-op, failure escalated, a failed spawn never caught by a zero-event transition) and through durable (Temple's probe as a permanent test: a strict decoder, InvokeActor with only onError, the delivery and the follow-up Fire both healthy, live and after Recover); and the replay compat case, journal built in-test by rewriting a record to drop the recorded type, in the style of the alias tests' rewrite harness. All are red on the parent commit. The two skipped #250 probes that the zero-event firing blocked are unskipped — a failed no-onError spawn now escalates, so a transition on the zero event never catches it and Recover retries the spawn — and the declared-but-unroutable onError case keeps its skip with the reason narrowed to the ErrNoTransition stopgap it actually is. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(durable): journal a service settle before the actor settle its absorb aborts on The High of the review's second pass: when a service's settle drove an actor whose own settle aborted in the same step, takeAborts failed the step and recorded nothing — including the service's own result, which had run and decoded. Recover left the service in flight, so RunService ran the ServiceFn again, and the abort recurred on every retry: three attempts, three runs, non-idempotent work (a payment) repeating. That contradicted the parking design's "never runs again" promise, which the comment beside the check and the RunService doc both leaned on. serviceStep now journals the service's settle — and the parent Fires the settle's absorb drove before the abort, which applied live — before it fails the Handle on the actor's abort. On Recover the service's settle replays from the journal, so the ServiceFn never runs again, however many Recover-and-retry rounds follow; only the actor re-runs, from its initial state, on each Recover's respawn of the still-running actor and on each redelivery. The Fire, Tick and DeliverToActor ends keep recording nothing: no service result is theirs to lose, and re-firing the event re-drives the actor. The new test drives fetch's onDone into a state that spawns a poker whose message to the parent finishes kid, whose done-data a strict decoder refuses, and walks three Recover-and-retry rounds: the first RunService settles fetch and fails on the aborted settle, and every later RunService finds fetch settled in the journal and runs nothing, while each redelivery fails on the actor alone. It is red on the parent commit — three ServiceFn runs. The RunService row of the undecodable- settle table is updated to the new contract, and its Fire and Tick rows still pin recording nothing. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(state,durable): report settle aborts through an observer and own the actor one settle at a time The Medium of the review's second pass, and the review's first-pass concurrency finding: abort reporting was Tick-only, but Tick's results are dropped by every delivery path — deliver, the sendTo / sendParent / respond / forwardTo sugar through dispatch, and Deliver — so a non-durable host on the transform got a silent abort, the actor stuck running with a final machine and an empty mailbox, and durable knew only through its own side channel, which noted aborts even for settles the system then suppressed as stale. The new ActorSystem.WithSettleAbortObserver — modeled on WithParentFireObserver — is called once for every settle that aborts, on every path that drives one, with a SettleAbort: the actor's id, the event the settle would have carried the outcome through, and the abort itself. It is the one channel a delivery's abort reaches, and the report is made only after the settle has rechecked its actor under the system lock, so a stale settle reports nothing. Durable wires it in place of the transform wrapper's own noting, which simplifies parentFires.aborted and stops noting aborts the system suppresses. One settle now owns the actor it settles, from its entry to its return: a settle that finds the actor already settled — SettleError on an already-settled, not-stopped actor is refused where it re-settled on main; that refusal gains a CHANGELOG line — or owned by a settle still in flight, another goroutine's or the transform's own reentrant call, returns the zero result and false, running no second transform against the winner's outcome, so a losing concurrent settle reports nothing, fires nothing and never overwrites the winner's recorded JSON. A Tick whose step produced the actor's real completion waits the owner out rather than dropping it, and a delivery whose actor is owned leaves its envelope queued for a later Tick. The -race test drives two concurrent settles on one id — a delivery's success and an aborting SettleError — and the reentrancy test pins the refusal a transform's own nested settle gets. Two more of the review's findings ride along in settle. The respawn drop (hearing) is now decided before the transform runs, so a settle a host's respawn replay throws away consults no decoder and can't abort on an outcome that differs on the respawn — Recover no longer fails for a dropped settle whose respawned child outputs something that won't encode. And a failure the transform rewrote into a success nothing routes escalates the ORIGINAL error, as the failure does with no transform: a transform may rewrite the outcome, not erase the failure — the escalation, LastOutput and LastError all pinned by new tests, with the UnboundActorError keep and the settled-actor refusal pinned too. Every new test is red on the parent commit where it can be: the vanishing failure, the respawn drop, and the observer tests (the API itself absent); the refusal and keep tests pin behavior the parent already had. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * test,docs: pin the remaining review findings on the abort and Start ends The rest of the review's medium findings, as pins and doc corrections, no behavior change: - A panicking actor's aborted settle: Tick's panic branch returns the abort as its one FireResult and reports it to the observer, as the done branch's test already pinned — killing the two `ok || res.Err != nil` mutants the review's mutation run left alive. - Start's aborted settle: the baseline checkpoint is already written, so a retry Start returns ErrInstanceExists and the retry is a Recover from the baseline, which re-runs the spawns; the Start comment, doc.go and fireStep now say so, and fireStep's says an actor the Fire's own transition spawned isn't respawned by the Recover that restores the pre-event state. Both pinned: the retry-Start test counts the spawn runs across the attempts, and the Fire's-own-spawn test proves the recovered Handle doesn't run the dynamic spawn and re-firing the event is what runs it again. - Panic wording pinned exactly: an actor error whose Error method panics settles with "actor error panicked: <recovered>", live and on replay, and a done-data with no JSON form fails the Handle with "actor done-data won't encode: <why>" — the actor seam's own words, so swapping them for the service seam's turns the tests red. - The Start end's StateAt now compares its notes to the live run's, as the Fire, Tick and RunService ends' do, not just its error. - durable's Changed entry on actor done-data decoding now says plainly what changes for callers reading AssignCtx.Event — without a decoder a struct arrives as a map, and errors are message-only so errors.Is and errors.As stop matching — and that WithEventDataDecoder is the opt-out. The move out of Added happened at 681f0ef; this finishes it. - The stale line in docs/durable/overview.md that still said a reducer sees the JSON-decoded shape only on replay now matches the README and doc.go: the done-data gets the same decode live as on replay. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * fix(state): keep a declared invoke outcome across an older machine's JSON, and retry a settle on a finished actor The re-review's blocker and its two mediums, on the declared-outcome flags and the abort a delivery can no longer recover through stepping. An older producer's JSON — a machine serialized before Invocation.HasOnDone / HasOnError existed, or a SpawnActor effect payload from before HasDone / HasError — never wrote the flags, so a reload decoded every declared outcome as unset and the invoked actor's success settled as the fire-and-forget no-op an outcome nothing declared is: the declared onDone was lost. The loads now back-fill each flag for an outcome whose key is absent and whose event is present and non-zero — an older producer set the event only when it declared it — so a reloaded definition keeps the outcomes it declared, an unset outcome (the zero event) still routes nothing, and a new producer's serialization round-trips byte-identically, flags, goldens and TestRoundTrip_Identity unchanged. The Invocation test is typed and exact; the SpawnActor effect's field is type-erased, so its zero test is on the decoded value's own type — exact for the scalar events a wire form distinguishes — and a composite event's declared outcomes reload from the typed IR instead of an aged payload. The CHANGELOG's sentence on pre-flags serializations now says all this. A delivery or Tick to a running actor whose machine is already final — an actor a settle's transform aborted left it that way — stepped the machine anyway, firing the delivered event into the final state, which failed as "state is final" and settled the actor as a failure through onError (or an escalation): the actor's completed outcome was misrouted as a crash. It now retries settling the final outcome instead, through the same ownership path as any settle — the optional finalActor interface the standard actorAdapter implements reports the final machine — so the transform runs again, an abort is reported again to the WithSettleAbortObserver, and once the transform stops aborting a later delivery or Tick lands the good output through onDone. The retry runs with an empty mailbox too, so a bare Tick settles an outcome a delivery's abort left unsettled. Nothing is misrouted through onError. Durable is unaffected: its live deliveries drive the same settle they always did, so the journal records the same entries, and its replay never delivers to an actor. The Deliver, Tick and WithSettleTransform docs and the CHANGELOG say so, and the stale claim that an abort is never recoverable through Deliver is gone. The WithSettleAbortObserver doc's backwards sentence is fixed too: observe runs inside settle's abort branch, before the abort reaches any caller, on every path, while the settle still owns the actor. Every behavioral test is red on the parent commit: the lost onDone, from the IR and from an aged effect payload, the misrouted retry through onError, and the empty Tick that left the outcome unsettled; the byte-identity and unset-outcome tests pin what the back-fill must not disturb. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> * chore(deps): bump OpenTelemetry to v1.47.0 for GO-2026-6974 GO-2026-6974 in go.opentelemetry.io/otel/trace is fixed in v1.47.0. The vulnerability scan fails on sink/gcppubsub, which reaches it through pubsub.Publisher.Publish. Bump otel, metric and trace (and sdk where used) to v1.47.0 in every module that pins them, then go mod tidy. govulncheck is clean in all 20 modules. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com> --------- Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this change does
Service results can keep their Go type, and a result that won't decode is parked instead of re-running the service.
durabledecodes a service result throughWithEventDataDecoder, keyed by the invocation's onDone event, live and on replay. With a decoder,Assignsees the registered type; without one, JSON's generic form, as main has it since fix(durable): dispatch effects from Start, Tick and RunService #235. A decoder that fails, or returns another type than the service did, parks the result.state.ServiceRunner.WithResultTransformtakes the event and can abort:func(event E, result any, err error) (out any, outErr error, abort error), run on every settle (Tick,SettleDone,SettleError). An abort fires no event and leaves the service in flight. Each activation carries a generation, so a stale settle, or a stale abort, settles nothing;Tickthen returns an empty slice.parkedServices), so the ServiceFn never runs again.Recoverwith a fixed decoder, thenRunService, settles it. A settled result also records its type, and replay refuses a decoder that returns another.Please check these
WithResultTransform's signature changes from the two-argument form fix(durable): dispatch effects from Start, Tick and RunService #235 merged. It's unreleased, so this breaks nothing shipped.Tickreturns an empty slice when the service was stopped, or stopped and re-armed, while its ServiceFn ran.errors.Isdoesn't match in onError.Assignran on a stand-in, then the Handle failed) is replaced: the result parks before anyAssignruns.service_undecodable_settle_test.gonow pins that.Scope: only what typed results need. Durable is unreleased, so there is no journal format bump and no old-journal handling; the journal stays at main's format 3. Pre-release compatibility follow-ups, such as a refused mixed-version journal still sending effects first, and the journal not recording which decoder a result was decoded with, are tracked in #253.
Relates to: #214, #235, #236, #237, #253
Closes #264.